package com.lantosec.hmrp.modules.form.vo;

import com.lantosec.hmrp.core.mvc.BaseVO;
import com.lantosec.hmrp.modules.form.entity.FormColumns;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * <p>
 * 自定义表单列定义 VO对象
 * </p>
 *
 * @author AutoCode
 * @since 2020-04-15
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value="Columns对象", description="自定义表单列定义")
public class FormColumnsVO extends BaseVO<FormColumns> {
    private static final long serialVersionUID = 1L;


    public FormColumnsVO(FormColumns entity){
        this.columnId = entity.getColumnId();
        this.tableId = entity.getTableId();
        this.columnName = entity.getColumnName();
        this.columnType = entity.getColumnType();
        this.ordinalPosition = entity.getOrdinalPosition();
        this.isNullable = entity.getIsNullable();
        this.dataType = entity.getDataType();
        this.characterMaximumLength = entity.getCharacterMaximumLength();
        this.numericPrecision = entity.getNumericPrecision();
        this.numericScale = entity.getNumericScale();
        this.datetimePrecision = entity.getDatetimePrecision();
        this.columnComment = entity.getColumnComment();
        this.primaryKey = entity.getPrimaryKey();
        this.foreignKey = entity.getForeignKey();
        this.primaryTableColumn = entity.getPrimaryTableColumn();
        this.valueType = entity.getValueType();
        this.valueData = entity.getValueData();
        this.createDate = entity.getCreateDate();
        this.createUserId = entity.getCreateUserId();
        this.createUserName = entity.getCreateUserName();
    }

    @Override
    public FormColumns convertToEntity(){
        return new FormColumns(this);
    }


    @ApiModelProperty(value = "ID")
    private String columnId;

    @ApiModelProperty(value = "表ID")
    private String tableId;

    @ApiModelProperty(value = "列名")
    private String columnName;

    @ApiModelProperty(value = "列类型，BASE COLUMN基础表列，EXT COLUMN扩展列")
    private String columnType;

    @ApiModelProperty(value = "排序")
    private Integer ordinalPosition;

    @ApiModelProperty(value = "是否允许为空，NO否YES是")
    private String isNullable;

    @ApiModelProperty(value = "数据类型")
    private String dataType;

    @ApiModelProperty(value = "字符的最大长度")
    private Long characterMaximumLength;

    @ApiModelProperty(value = "数值精度")
    private Long numericPrecision;

    @ApiModelProperty(value = "数值刻度")
    private Long numericScale;

    @ApiModelProperty(value = "日期刻度")
    private Long datetimePrecision;

    @ApiModelProperty(value = "列描述")
    private String columnComment;

    @ApiModelProperty(value = "是否主键")
    private Boolean primaryKey;

    @ApiModelProperty(value = "是否外键")
    private Boolean foreignKey;

    @ApiModelProperty(value = "对应主表的列")
    private String primaryTableColumn;

    @ApiModelProperty(value = "值类型，DEFAULT默认值，SQL查询值，SQL LIST查询列表，DICTIONARIES字典，JAVASCRIPT MATH js公式，JAVA MATH java公式")
    private String valueType;

    @ApiModelProperty(value = "值数据")
    private String valueData;

    @ApiModelProperty(value = "创建时间")
    private Date createDate;

    @ApiModelProperty(value = "创建用户ID")
    private String createUserId;

    @ApiModelProperty(value = "创建用户名称")
    private String createUserName;


    @ApiModelProperty(value = "字段属性")
    private String columnKey;

    @ApiModelProperty(value = "扩展")
    private String extra;

}
